CON

  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

  SDA_PIN       = 29
  SCL_PIN       = 28
  ACK           = 0
  NAK           = 1

obj

  'i2c   :       "Basic_I2C_Driver"  
  i2c   :       "new_i2c"
  d     :       "Parallax Serial Terminal"
  l     :       "lib"      
  
pub go | i, bob, x

  d.start(115_200)
  
  l.PauseMS(500)
  d.clear

  i2c.StartI2C(SDA_PIN, SCL_PIN)
  
  d.str(string("Sending to Restep", 13))

  x~
  repeat

    i2c.ResetBus                'Not required but may not be a bad idea
    
    repeat 800
    
    i2c.SendStart
    i2c.TxByte($EA & !$01)      'Slave Address + Write command
    i2c.TxByte($56)             '<---- First byte to send
    i2c.TxByte($56)             '<---- Second byte to send
    i2c.SendStop

    repeat 200
    
    i2c.SendStart
    i2c.TxByte($EA | $01)      'Slave Address + Read command

    d.hex(i2c.RxByte(ACK), 4)  '<---- First byte read back
    d.char(13)
    d.hex(i2c.RxByte(NAK), 4)  '<---- Second byte read back
                               
    i2c.SendStop

    d.char(13)
    d.char(13)

    waitcnt(cnt + clkfreq/10)


  d.str(string("done", 13))   
  repeat